package com.pool.common;

import android.content.res.Resources;

/**
 * Common methods and values related to {@link String}s.
 * 
 * @author claveld@gmail.com (David Clavel)
 */
public class Strings {

  private static Resources applicationResources = null;
  
  public static void setApplicationResources(Resources applicationResources) {
    Strings.applicationResources = applicationResources;
  }
  
  /**
   * Returns whether a {@link String} is empty or not.
   */
  public static boolean isEmpty(String string) {
    return string == null || string.trim().length() == 0;
  }
  
  /**
   * Returns true if any of the given {@link String}s is empty.
   */
  public static boolean anyEmpty(String ... strings) {
    for (String string : strings) {
      if (isEmpty(string)) {
        return true;
      }
    }
    return false;
  }
  
  /**
   * Returns the {@link String} associated to a string resource id.
   */
  public static String getString(int id) {
    return applicationResources.getString(id);
  }
}
